home *** CD-ROM | disk | FTP | other *** search
- unit Appsuprt;
-
- interface
- uses DB;
- const
- FieldTypeStr : array[ftunknown..ftgraphic] of string[8] =
- ('Unknown', 'String', 'Smallint', 'Integer', 'Word',
- 'Boolean', 'Float', 'Currency', 'BCD', 'Date', 'Time',
- 'DateTime', 'Bytes', 'VarBytes', 'Blob', 'Memo', 'Graphic');
- FieldTypeLtr : array[ftunknown..ftgraphic] of string[1] =
- ('U', 'S', 'i', 'I', 'W',
- 'L', 'F', 'C', 'B', 'D', 'T',
- 'A', 'y', 'V', 'o', 'M', 'G');
-
-
- type
- PFieldDef = ^FieldDefRecType;
- FieldDefRecType = record
- fieldname : string[20];
- scrprompt : string[20]; {tfield.DisplayName}
- scrformat : string[20]; {tfield.DisplayText -- an editmask}
- grdprompt : string[10];
- grdwidth : integer; {tfield.DisplayWidth}
- fldtype : string[1]; {FieldTypeLtr}
- fldlen : integer; {tfield.size}
- flddec : integer;
- fldidx : boolean;
- idxexp : string;
- taborder : integer;
- required : boolean; {tfield.required}
- default : string[80];
- editmask : string[80]; {tfield.editMask}
- validvalue : pchar;
- {for numerics: minvalue, maxvalue}
- {for strings: comma delimited list}
- hint : string;
- helpid : longint;
- haslink : boolean;
- srclinktbl : string[20];
- srclinkfld : string[20];
- iscalc : boolean;
- next, prev : pFieldDef;
- end;
-
- PtableDef = ^TableDefRecType;
- TableDefRecType = record
- Query : tQuery;
- tablename : string[20];
- fieldDefs : PFieldDef;
- next, prev : PTableDef;
- end;
-
-
- TDBdict = class(tobject);
- TableDef : PTableDef;
- procedure FillTableDef(dict : tdatasource);
- end;
-
- var
- DBdict : TDBdict;
-
- implementation
-
- procedure TdbDict.FillTableDef(dict : tdatasource);
- begin
- query.dataSource := Dict;
- query.databasename := dict.databasename;
- query.close;
- query.sql.clear;
- query.params.clear;
- sqlstr := 'SELECT * FROM '+DDTableName;
- query.sql.add(sqlstr);
- query.prepare;
- query.open;
- query.first;
- { get tablenames in data dictionary, stick in M_tableList lines}
- if query.findfield('TABLE_NAME') = nil
- then begin
- cursor := crDefault;
- MessageDlg(DDListBox.items[whichone]+#13+'is not a Data Dictionary Database.', mtInformation, [mbOK], 0);
- m_status.hide;
- result := ExistButNotDD;
- exit;
- end;
- m_tableList.lines.add(query.findfield('TABLE_NAME').text); {get first one}
- inc(numfields);
- query.next;
- while not query.eof do begin
- tablefound := false;
- thistable := query.findfield('TABLE_NAME').text;
- inc(numFields);
- for tablenum := 0 to m_tablelist.lines.count - 1 do
- if m_tableList.lines[tablenum] = thistable
- then begin
- tablefound := true;
- break;
- end;
- {done looking for thistable}
- if not tablefound
- then m_tablelist.lines.add(thistable);
- query.next;
- end; {while searching for table names}
- except
- on EdataBaseError do begin
- cursor := crDefault;
- MessageDlg('Not a data base file or other DB error', mtInformation, [mbOK], 0);
- l_size.caption := '';
- l_update.caption := '';
- m_status.hide;
- result := ExistbutnotDD;
- end;
- end; {of exceptions}
-
-
-
-
-
- end.
-